/***************************************************
Class: Camera
Includes: stdafx.h
Editors: Gindi
Existing Issues: None
Description: Creates and manipulates a 3D camera.
***************************************************/
#pragma once

#include "stdafx.h"

class Camera {
public:
	Camera();
	~Camera() {}
	
	void setProjection(float fov, float aspect, float nearPlane, float farPlane);
	void moveForward(float units);		// can move backwards using a (-) number
	void moveSideways(float units);		// (+) to move right, (-) to move left (strafing)
	void Update(D3DXVECTOR3*, bool cameraTDView);
	bool sphereInFrustrum(D3DXVECTOR3* position, float radius);

	void setPosition(D3DXVECTOR3* position);
	void setLook(D3DXVECTOR3* look);
	void setFOV(float fov)				{ setProjection(m_fov, m_aspect, m_nearPlane, m_farPlane); }
	void setAspectRatio(float aspect)	{ setProjection(m_fov, aspect, m_nearPlane, m_farPlane); }
	void setNearPlane(float plane)		{ setProjection(m_fov, m_aspect, plane, m_farPlane); }
	void setFarPlane(float plane)		{ setProjection(m_fov, m_aspect, m_nearPlane, plane); }

	D3DXMATRIX* getViewMatrix()			{ return &m_view; }
    D3DXMATRIX* getProjectionMatrix()	{ return &m_projection; }
    D3DXVECTOR3* getPosition()			{ return &m_position; }
    D3DXVECTOR3* getLook()				{ return &m_look; }
    float getFOV()						{ return m_fov; }
    float getAspectRatio()				{ return m_aspect; }
    float getNearPlane()				{ return m_nearPlane; }
    float getFarPlane()					{ return m_farPlane; }

private:
	void BuildViewFrustum();

	D3DXMATRIX		m_view;
	D3DXMATRIX		m_projection;
	D3DXVECTOR3		m_right;
	D3DXVECTOR3		m_up;
	D3DXVECTOR3		m_look;
	D3DXVECTOR3		m_position;
	D3DXPLANE		m_frustum[6];
	float			m_fov;
	float			m_aspect;
	float			m_nearPlane;
	float			m_farPlane;
};
